#include "apue.h"
#include <dirent.h>
#include "errno.h"

int main(int argc, char *argv[])
{
	int i;
	DIR *dp;
	struct dirent *dirp;
	if (argc != 2)
		err_quit("usage: ls directory_name");
	if((dp = opendir(argv[1])) == NULL)
		err_sys("can't open %s", argv[1]); 
	while  ((dirp = readdir(dp)) != NULL)
		printf("%s\n", dirp->d_name);
	closedir(dp);
	for(i = 0; i<argc;i++ ){
        printf("i=%d, argv[%d]= %s ", i, i, argv[i]);
        printf("*(argv+i)= %s ", *(argv+i));
        printf("*argv=%s\n", *(argv+i));
        printf("argv=%p\n",(argv+i));
        printf("&argv= %p\n", &argv[i]);
        printf("*argv[%d] = %c\n ", i, *argv[i]);
    }

	exit(0);

}

